import java.util.Scanner;

public class two {
    public static void main(String[] args) {

        int count = 0;
        while (count < 3) {
            try {
                login();
            } catch (MyException e){
                count ++ ;
                System.out.println(e.getMessage());
                continue;
            } catch (Exception e) {
                count ++ ;
                System.out.println(e.getMessage());
                System.out.println(new MyException().getMessage());
                continue;
            }

            break;
        }
        if (count < 3) System.out.println("登录成功");
        else System.out.println("登录失败");

    }
    public static void login() throws MyException {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        if (!str1.equals("111") || !str2.equals("222")) {
            MyException e = new MyException();
            throw e;
        }

    }
}
